<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('修改实习期转正人员')"/>
    <th:block th:include="include :: layout-latest-css"/>
    <th:block th:include="include :: ztree-css"/>
    <th:block th:include="include :: select2-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-internshipJust-edit" AUTOCOMPLETE="OFF">
        <input name="id" id="id" type="hidden" th:value="${editInternshipJustEmp.id}"/>
        <div class="form-group">
            <label class="col-sm-3 control-label ">工号：</label>
            <div class="col-sm-8">
                <input class="form-control" id="badge" type="text" th:value="${editInternshipJustEmp.badge}"
                       readonly="readonly"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">姓名：</label>
            <div class="col-sm-8">
                <input class="form-control" id="name" type="text" th:value="${editInternshipJustEmp.name}"
                       readonly="readonly"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">公司名称：</label>
            <div class="col-sm-8">
                <input class="form-control" id="compName" type="text" th:value="${editInternshipJustEmp.compName}"
                       readonly="readonly"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">部门名称：</label>
            <div class="col-sm-8">
                <input class="form-control" id="depName" type="text" th:value="${editInternshipJustEmp.depName}"
                       readonly="readonly"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">岗位名称：</label>
            <div class="col-sm-8">
                <input class="form-control" id="jobName" type="text" th:value="${editInternshipJustEmp.jobName}"
                       readonly="readonly"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">入职时间：</label>
            <div class="col-sm-8">
                <input class="form-control" id="JoinDate" type="text" th:value="${editInternshipJustEmp.joindate}"
                       readonly="readonly"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">实习期(月)：</label>
            <div class="col-sm-8">
                <input class="form-control" id="Practerm" type="text" th:value="${editInternshipJustEmp.Practerm}"
                       readonly="readonly"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label ">实习结束日期：</label>
            <div class="col-sm-8">
                <input class="form-control" id="PracEndDate" type="text" th:value="${editInternshipJustEmp.PracEndDate}"
                       readonly="readonly"/>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label "><span style="color: red; ">*</span>评估结果：</label>
            <div class="col-sm-8">
                <select name="Result" id="Result" class="form-control"
                        th:with="type=${@dict.getType('eCD_PracResult')}">
                    <option value="">请选择</option>
                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                            th:selected="${editInternshipJustEmp.Result+'' == dict.dictValue}"
                            th:value="${dict.dictValue}"></option>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label "><span style="color: red; ">*</span>实习转正日期：</label>
            <div class="col-sm-8">
                <input class="form-control laydate-demo-1" id="effectdate" name="effectdate" type="text"
                       th:value="${editInternshipJustEmp.effectdate}" required/>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label ">是否试用：</label>
            <div class="col-sm-8">
                <select name="toprob" id="toprob" class="form-control">
                    <option value="">请选择</option>
                    <option value="1" th:selected="${editInternshipJustEmp.toprob == true}">是</option>
                    <option value="0"
                            th:selected="${editInternshipJustEmp.toprob == false || editInternshipJustEmp.toprob == '' }">
                        否
                    </option>
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label ">试用期：</label>
            <div class="col-sm-8">
                <input class="form-control" id="probterm" name="probterm" type="text"
                       th:value="${editInternshipJustEmp.probterm}" oninput="value=value.replace(/[^\d]/g,'')"
                       required/>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label ">试用结束日期：</label>
            <div class="col-sm-8">
                <input class="form-control laydate-demo-2" id="probenddate" name="probenddate" type="text"
                       th:value="${editInternshipJustEmp.probenddate}" required/>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label "><span style="color: red; ">*</span>新工作岗位：</label>
            <div class="col-sm-8">
                <select class="form-control" name="newJob" id="newJob">
                </select>
            </div>
        </div>

        <div class="form-group">
            <label class="col-sm-3 control-label ">备注：</label>
            <div class="col-sm-8">
                <input class="form-control" id="remark" name="remark" type="text"
                       th:value="${editInternshipJustEmp.remark}"/>
            </div>
        </div>

    </form>
</div>


<th:block th:include="include :: footer"/>
<th:block th:include="include :: select2-js"/>
<th:block th:include="include :: datetimepicker-js"/>

<script th:inline="javascript">

    var prefix = ctx + "changeManage/InternshipChangeJust";


    $(function () {

        var depList = [[${editInternshipJustEmp.jonList}]];
        var newJob = [[${editInternshipJustEmp.newJob}]];
        console.log(newJob);
        var html = "";
        html += "<option value=''>请选择</option>";
        for (var i = 0; i < depList.length; i++) {
            html += "<option value='" + depList[i].jobId + "'>" + depList[i].title + "";
        }
        $("#newJob").append(html);

        $("#newJob").find("option").each(function () {
            if ($(this).val() == newJob) {
                $(this).attr("selected", true);
            }
        });

        console.log(depList);

        layui.use('laydate', function () {
            var laydate = layui.laydate;
            laydate.render({
                elem: '.laydate-demo-1',
                type: 'date'
            });
        });

        layui.use('laydate', function () {
            var laydate = layui.laydate;
            laydate.render({
                elem: '.laydate-demo-2',
                type: 'date'
            });
        });

    });

    function submitHandler() {
        if ($.validate.form()) {
            var data = $("#form-internshipJust-edit").serializeArray();
            var id = $("#id").val();
            var Result = $("#Result").val();
            var effectdate = $("#effectdate").val();
            var toprob = $("#toprob").val();
            var probterm = $("#probterm").val();
            var probenddate = $("#probenddate").val();
            var newJob = $("#newJob").val();
            var remark = $("#remark").val();

            if (Result == "" || Result == null) {
                $.modal.alertWarning("请选择评估结果!");
                return;
            } else if (effectdate == "" || effectdate == null) {
                $.modal.alertWarning("请填写实习转正日期!");
                return;
            } else if (newJob == "" || newJob == null) {
                $.modal.alertWarning("请选择新工作岗位!");
                return;
            }
            data.push({"name": "id", "value": id});
            data.push({"name": "Result", "value": Result});
            data.push({"name": "effectdate", "value": effectdate});
            data.push({"name": "toprob", "value": toprob});
            data.push({"name": "probterm", "value": probterm});
            data.push({"name": "probenddate", "value": probenddate});
            data.push({"name": "newJob", "value": newJob});
            data.push({"name": "remark", "value": remark});

            $.operate.save(prefix + "/edit", data);
        }
    }
</script>


</body>
</html>